/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package py.com.peluq.model.entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Diego_M
 */
@Entity
@Table(name = "compra_cab", catalog = "peludb", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "CompraCab.findAll", query = "SELECT c FROM CompraCab c"),
    @NamedQuery(name = "CompraCab.findByIdcompraCab", query = "SELECT c FROM CompraCab c WHERE c.compraCabPK.idcompraCab = :idcompraCab"),
    @NamedQuery(name = "CompraCab.findByFecha", query = "SELECT c FROM CompraCab c WHERE c.compraCabPK.fecha = :fecha"),
    @NamedQuery(name = "CompraCab.findByNroFactura", query = "SELECT c FROM CompraCab c WHERE c.compraCabPK.nroFactura = :nroFactura"),
    @NamedQuery(name = "CompraCab.findByIdproveedores", query = "SELECT c FROM CompraCab c WHERE c.compraCabPK.idproveedores = :idproveedores"),
    @NamedQuery(name = "CompraCab.findByTipo", query = "SELECT c FROM CompraCab c WHERE c.tipo = :tipo"),
    @NamedQuery(name = "CompraCab.findByMonto", query = "SELECT c FROM CompraCab c WHERE c.monto = :monto"),
    @NamedQuery(name = "CompraCab.findByIntervalo", query = "SELECT c FROM CompraCab c WHERE c.intervalo = :intervalo"),
    @NamedQuery(name = "CompraCab.findByCuotas", query = "SELECT c FROM CompraCab c WHERE c.cuotas = :cuotas"),
    @NamedQuery(name = "CompraCab.findByEstados", query = "SELECT c FROM CompraCab c WHERE c.estados = :estados")})
public class CompraCab implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected CompraCabPK compraCabPK;
    @Column(name = "tipo")
    private Integer tipo;
    @Column(name = "monto")
    private Integer monto;
    @Column(name = "intervalo")
    private Integer intervalo;
    @Column(name = "cuotas")
    private Integer cuotas;
    @Column(name = "estados")
    private Integer estados;
    @ManyToMany(mappedBy = "compraCabCollection")
    private Collection<Productos> productosCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "compraCab")
    private Collection<CtaPagar> ctaPagarCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "compraCab")
    private Collection<OrdenCompra> ordenCompraCollection;
    @JoinColumn(name = "idproveedores", referencedColumnName = "idproveedores", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Proveedores proveedores;
    @JoinColumn(name = "idsucursal", referencedColumnName = "idsucursal", nullable = false)
    @ManyToOne(optional = false)
    private Sucursal idsucursal;

    public CompraCab() {
    }

    public CompraCab(CompraCabPK compraCabPK) {
        this.compraCabPK = compraCabPK;
    }

    public CompraCab(int idcompraCab, int fecha, int nroFactura, int idproveedores) {
        this.compraCabPK = new CompraCabPK(idcompraCab, fecha, nroFactura, idproveedores);
    }

    public CompraCabPK getCompraCabPK() {
        return compraCabPK;
    }

    public void setCompraCabPK(CompraCabPK compraCabPK) {
        this.compraCabPK = compraCabPK;
    }

    public Integer getTipo() {
        return tipo;
    }

    public void setTipo(Integer tipo) {
        this.tipo = tipo;
    }

    public Integer getMonto() {
        return monto;
    }

    public void setMonto(Integer monto) {
        this.monto = monto;
    }

    public Integer getIntervalo() {
        return intervalo;
    }

    public void setIntervalo(Integer intervalo) {
        this.intervalo = intervalo;
    }

    public Integer getCuotas() {
        return cuotas;
    }

    public void setCuotas(Integer cuotas) {
        this.cuotas = cuotas;
    }

    public Integer getEstados() {
        return estados;
    }

    public void setEstados(Integer estados) {
        this.estados = estados;
    }

    @XmlTransient
    public Collection<Productos> getProductosCollection() {
        return productosCollection;
    }

    public void setProductosCollection(Collection<Productos> productosCollection) {
        this.productosCollection = productosCollection;
    }

    @XmlTransient
    public Collection<CtaPagar> getCtaPagarCollection() {
        return ctaPagarCollection;
    }

    public void setCtaPagarCollection(Collection<CtaPagar> ctaPagarCollection) {
        this.ctaPagarCollection = ctaPagarCollection;
    }

    @XmlTransient
    public Collection<OrdenCompra> getOrdenCompraCollection() {
        return ordenCompraCollection;
    }

    public void setOrdenCompraCollection(Collection<OrdenCompra> ordenCompraCollection) {
        this.ordenCompraCollection = ordenCompraCollection;
    }

    public Proveedores getProveedores() {
        return proveedores;
    }

    public void setProveedores(Proveedores proveedores) {
        this.proveedores = proveedores;
    }

    public Sucursal getIdsucursal() {
        return idsucursal;
    }

    public void setIdsucursal(Sucursal idsucursal) {
        this.idsucursal = idsucursal;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (compraCabPK != null ? compraCabPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CompraCab)) {
            return false;
        }
        CompraCab other = (CompraCab) object;
        if ((this.compraCabPK == null && other.compraCabPK != null) || (this.compraCabPK != null && !this.compraCabPK.equals(other.compraCabPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "py.com.peluq.model.entity.CompraCab[ compraCabPK=" + compraCabPK + " ]";
    }
    
}
